<!--
	作者：罗德阿
	时间：2018-08-28
	描述：将时间戳转为字符串格式
-->
<template>
	<span>{{dateTime}}</span>
</template>

<script>
	export default {
		name: "DateFormat",
		props: {
			datetime: {
				type: Number,
				default: function() {
					return null;
				}
			},
			format: {
				type: String,
				default: function() {
					return "yyyy-MM-dd HH:mm:ss";
				}
			}
		},
		data() {
			return {
				dateTime: ""
			}
		},
		watch: {
			datetime: function(datetime) {
				this.dateTime = new Date(datetime).Format(this.format);
			}
		},
		updated() {
			this.dateTime = new Date(this.datetime).Format(this.format);
		},
		mounted() {
			this.dateTime = new Date(this.datetime).Format(this.format);
		}
	}
</script>

<style>

</style>